<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>影院资料维护</title>
    <jsp:include page="/IncludeJS.jsp"></jsp:include>
</head>
<body onload="init();">
<script type="text/javascript">
    function save() {
        document.forms[0].submit();
    }

    function check() {
        if ($("#agentName").val() == "") {
            alert("请输入影院名称");
            $('#agentName').focus();
            return false;
        }
        if ($("#provinceId").val() == "0") {
            alert("请选择省份");
            $('#provinceId').focus();
            return false;
        }
        if ($("#contact").val() == "") {
            alert("请输入联系人");
            $('#contact').focus();
            return false;
        }
        if ($("#mobile").val() == "") {
            alert("请输入联系方式");
            $('#mobile').focus();
            return false;
        }
        if ($("#address").val() == "") {
            alert("请输入影院地址");
            $('#address').focus();
            return false;
        }
        return true;
    }

    function back() {
        location.href = "${pageContext.request.contextPath }/agent/list";
    }

    if ("${msg}" != null && "${msg}".length > 0) {
        alert("${msg}");
    }

    function init() {
        var key = $("#id").val();
        if (key == "") {
            var d = new Date();
            var y = d.getFullYear();
            var m = d.getMonth() + 1;
            var d = d.getDate();
            $("#registerTime").datebox("setValue", y + "-" + m + "-" + d);
        } else {
            var td = $("#registerTime").val();
            if (td != "" && td.substring(0, 1) != '2') {
                td = "20" + td;
                $("#registerTime").datebox("setValue", td.substring(0, 10));
            }
        }
    }

    function changeProvince() {
        var provid = $("#provinceId").val();
        var url = "${pageContext.request.contextPath }/agent/cityList";
        $.post(
            url,
            {
                "provinceId": provid
            },
            function (data) {
                $("#cityId").empty();
                $.each(data.cityList, function (i, item) {
                    $("#cityId").append("<option value='" + item.cityId + "'>" + item.cityName + "</option>");
                });
            },
            "json"
        );
    }
</script>
<table width="100%" border="0" cellpadding="0" cellspacing="0" BACKGROUND="images/maintitle.jpg">
    <tr>
        <td align="left">
            <a class="easyui-linkbutton" plain="true" icon="icon-undo" href="javascript:void(0);"
               onclick="back();">返回</a>
        </td>
    </tr>
</table>
<form action="${pageContext.request.contextPath }/agent/save" enctype="multipart/form-data" method="post"
      onsubmit="return check();">
    <input type="hidden" name="agentId" id="id" value="${agent.agentId}"/>
    <table cellpadding="0" cellspacing="0" border="0" style="margin: 0 auto" align="left">
        <tr height="30">
            <td align="right" width="130">影院名称</td>
            <td><input type="text" name="agentName" id="agentName" style="width:250px" value="${agent.agentName}"/><font
                    size="2" color="red">*</font></td>
            <td align="right">影院图标</td>
            <td><input type="file" name="file1" id="file1"></td>
            <td rowspan="5" valign="top"><img src="${pageContext.request.contextPath }/${agent.agentIcon}" width="150"
                                              align="top"></td>
        </tr>
        <tr height="30">
            <td align="right">省份名称</td>
            <td>
                <select name="provinceId" id="provinceId" onchange="changeProvince();" style="width:250px">
                    <c:forEach items="${provinceList}" var="v">
                        <c:if test="${agent.provinceId==v.provinceId}">
                            <option value="${v.provinceId}" selected>${v.provinceName}</option>
                        </c:if>
                        <c:if test="${agent.provinceId!=v.provinceId}">
                            <option value="${v.provinceId}">${v.provinceName}</option>
                        </c:if>
                    </c:forEach>
                </select>
            </td>
            <td align="right">城市名称</td>
            <td>
                <select name="cityId" id="cityId" style="width:250px">
                    <c:forEach items="${cityList}" var="v">
                        <c:if test="${agent.cityId==v.cityId}">
                            <option value="${v.cityId}" selected>${v.cityName}</option>
                        </c:if>
                        <c:if test="${agent.cityId!=v.cityId}">
                            <option value="${v.cityId}">${v.cityName}</option>
                        </c:if>
                    </c:forEach>
                </select>
            </td>

        </tr>
        <tr height="30">
            <td align="right" width="90">状态</td>
            <td>
                <select name="invalid" id="invalid" style="width:250px">
                    <option value="1" <c:if test="${agent.invalid==1}">selected</c:if>>启用</option>
                    <option value="0" <c:if test="${agent.invalid==0}">selected</c:if>>禁用</option>
                </select>
            </td>
            <td align="right" width="120">入驻日期</td>
            <td><input type="text" name="registerTime" id="registerTime" style="width:250px" class="easyui-datebox"
                       value="${agent.registerTime}"/></td>
        </tr>
        <tr height="30">
            <td align="right" width="90">联系人</td>
            <td><input type="text" name="contact" id="contact" style="width:250px" value="${agent.contact}"/><font
                    size="2" color="red">*</font></td>
            <td align="right" width="120">联系方式</td>
            <td><input type="text" name="mobile" id="mobile" style="width:250px" value="${agent.mobile}"/><font size="2"
                                                                                                                color="red">*</font>
            </td>
        </tr>
        <tr height="30">
            <td align="right" width="90" style="vertical-align: top">停车服务</td>
            <td>
                <input type="text" name="carPark" id="carPark" style="width:250px" value="${agent.carPark }">
            </td>
            <td align="right" width="90" style="width:250px">3D眼镜</td>
            <td>
                <input type="text" name="glasses" id="glasses" style="width:250px" value="${agent.glasses }">
            </td>
        </tr>
        <tr height="30">
            <td align="right" width="90" style="width:250px">儿童优惠</td>
            <td><input type="text" name="children" id="children" style="width:250px"
                       value="${agent.children }"></td>

            <%--            <td align="right" width="90" style="width:250px">星级&nbsp;</td>--%>
            <%--            <td align="right">--%>
            <%--                <input id="one-star" type="radio" name="s-level" value="1">--%>
            <%--                <label for="one-star"> 一星级</label>--%>

            <%--                <input id="two-star" type="radio" name="s-level" value="2">--%>
            <%--                <label for="two-star">二星级</label>--%>

            <%--                <input id="three-star" type="radio" name="s-level" value="3">--%>
            <%--                <label for="three-star">三星级</label>--%>

            <%--                <input id="four-star" type="radio" name="s-level" value="4">--%>
            <%--                <label for="four-star">四星级</label>--%>

            <%--                <input id="five-star" type="radio" name="s-level" value="5">--%>
            <%--                <label for="five-star">五星级</label>--%>
            <%--            </td>--%>
        </tr>
        <tr height="30">
            <td align="right" width="90" style="width:250px">星级&nbsp&nbsp</td>
            <%--   星级选项         --%>
            <td colspan="3">
                <input id="one-star" type="radio" name="star" value="1"
                       <c:if test="${agent.star == 1}">checked</c:if>
                >
                <label for="one-star"> 一星级</label>

                <input id="two-star" type="radio" name="star" value="2"
                       <c:if test="${agent.star == 2}">checked</c:if>
                >
                <label for="two-star">二星级</label>

                <input id="three-star" type="radio" name="star" value="3"
                       <c:if test="${agent.star == 3}">checked</c:if>
                >
                <label for="three-star">三星级</label>

                <input id="four-star" type="radio" name="star" value="4"
                       <c:if test="${agent.star == 4}">checked</c:if>
                >
                <label for="four-star">四星级</label>

                <input id="five-star" type="radio" name="star" value="5"
                       <c:if test="${agent.star == 5}">checked</c:if>
                >
                <label for="five-star">五星级</label>
            </td>
        </tr>
        <tr height="30">
            <td align="right" width="90">联系地址</td>
            <td colspan="3"><input type="text" name="address" id="address" style="width:760px" value="${agent.address}">
            </td>
        </tr>
        <tr height="30">
            <td>&nbsp;</td>
            <td colspan="3"><input type="submit" value="   保 存   "></input></td>
        </tr>
    </table>
</form>
</body>
</html>